1 Basic illustrations

1.1 R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

1.2 Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

1.3 Including a table

A caption
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.1 3.5 1.4 0.2 setosa
4.9 3.0 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5.0 3.6 1.4 0.2 setosa

1.4 Inline r code

The average yield is 104.5701349.

2 Markdown basics (level 1 header)

2.1 level 2 header

2.1.1 level 3 header

See the source rmd file:

  • list item 1
  • list item 2
  • list item 3
  • italics
  • bold
  • code (do not put r right after the first tick mark)
  • inline math: I hate math. What does this \(\int_a^b f(x)dx\) even mean?
  • math: \[\sum_{i=1}^n x_i/n\]
  • link: Markdown basics
  • citationL: The best resource to learn how to use Rmarkdown is [@xie2018r].

3 Chunk options

3.1 echo and eval

R code and results

##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

R code suppressed

##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Only R code (R code was not evaluated)

Both R codes and results not shown


3.2 messages and warnings

3.2.1 both messages and warnings

## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.6
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()

3.2.2 messages suppressed

3.2.3 both messages and warnings suppressed


3.3 results

No results are shown.

But, this shows the above code was evaluated and object a was created.

##   [1] 0.350349978 0.462961236 0.113930023 0.174954225 0.170794062 0.692183580
##   [7] 0.594846918 0.108901789 0.192909662 0.767943610 0.643715249 0.204480004
##  [13] 0.811863986 0.250452001 0.592385723 0.455391258 0.156572630 0.446857813
##  [19] 0.379850575 0.320651675 0.894127643 0.006882706 0.768682064 0.998470782
##  [25] 0.264791884 0.678178260 0.694719936 0.930123904 0.034711960 0.699248383
##  [31] 0.946193314 0.142036333 0.561562106 0.049861000 0.816663454 0.820352075
##  [37] 0.452741143 0.063522938 0.722392725 0.720759323 0.064292517 0.242588780
##  [43] 0.794172431 0.823621822 0.730496784 0.396951622 0.907722458 0.713651714
##  [49] 0.804905373 0.847965190 0.541036627 0.564436201 0.407830226 0.667268012
##  [55] 0.277183371 0.679271965 0.346870973 0.692321878 0.129938756 0.921728347
##  [61] 0.914437613 0.771757945 0.887645973 0.414095334 0.484922018 0.901446478
##  [67] 0.731437017 0.268911513 0.553278452 0.158925594 0.451630498 0.121996131
##  [73] 0.510852352 0.424533339 0.339447412 0.183757645 0.459291716 0.912609611
##  [79] 0.383858969 0.896177272 0.801157310 0.009233527 0.341500588 0.542254291
##  [85] 0.158979408 0.932199056 0.706849628 0.229528976 0.117932425 0.173632829
##  [91] 0.413076432 0.509131103 0.517910171 0.586827479 0.564893162 0.210912060
##  [97] 0.281101293 0.010776010 0.478054321 0.623597397

3.4 include = FALSE

No results are shown.

But, this shows the above code was evaluated and object a was created.

##   [1] 0.432755550 0.165662263 0.494497007 0.513510063 0.389520589 0.825907012
##   [7] 0.158607424 0.517705345 0.742594786 0.850320895 0.766178553 0.895417884
##  [13] 0.677629195 0.193991130 0.569156493 0.236197319 0.646050078 0.963014559
##  [19] 0.146671619 0.240249194 0.215842424 0.692349957 0.388789160 0.268796646
##  [25] 0.455459617 0.504718999 0.998614138 0.894502518 0.043829975 0.342263919
##  [31] 0.755652204 0.024545879 0.153506475 0.401038759 0.368672557 0.387309436
##  [37] 0.198668671 0.334165278 0.874041097 0.125209298 0.794027489 0.921342529
##  [43] 0.718627725 0.813465691 0.558696928 0.404679572 0.254410440 0.136160392
##  [49] 0.931873044 0.949969484 0.332159783 0.605401500 0.300705315 0.720055781
##  [55] 0.035243671 0.395915923 0.962534831 0.295649291 0.319097202 0.589422338
##  [61] 0.005535505 0.965867588 0.621694700 0.323932148 0.383581850 0.080525472
##  [67] 0.167485865 0.273585262 0.998870753 0.065502524 0.155752643 0.689883248
##  [73] 0.905547015 0.215939532 0.202750838 0.006248704 0.378182829 0.282803346
##  [79] 0.930805537 0.235225616 0.591660779 0.914137021 0.246989580 0.914661225
##  [85] 0.559775507 0.553047433 0.153801772 0.952906096 0.099300105 0.422490828
##  [91] 0.831821156 0.024668382 0.535494362 0.039895258 0.810180390 0.988930806
##  [97] 0.019438346 0.726748163 0.214647833 0.247137778

4 Caching

## [1] 1.500241
## [1] 1.500241

5 Interactive features: htmlwidgets

5.1 interactive data table

5.2 Interactive time-series data

5.3 Interactive ggplot2 figures

## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout